Terraform

What is Terraform?

Terraform is developed by HashiCorp, it was an open-source infrastructure as code (IaC) software tool for building, changing, and versioning infrastructure. It enables users to define and provision infrastructure resources using a declarative configuration language. With Terraform, infrastructure is defined in code using a domain-specific language (DSL) - often HashiCorp Configuration Language (HCL), allowing for versioning, collaboration, and automation of infrastructure deployments. Terraform supports various cloud providers, including Amazon AWS, Microsoft Azure, Google Cloud Platform, as well as on-premises and hybrid environments. This means users can use the same tool for GCP, Azure, and AWS, and maintain a degree of cloud-agnosticism long-term.

There are two drivers to cloud agnostic tooling:

  • Many organizations want to avoid vendor lock in especially with respect to pricing models and so want to avoid in investing in single-cloud cloud native technologies
  • The different cloud providers have their own strengths: Azure is strong with the AVD / Win10/11 DaaS market, Google (GCP) are strong on geography and maps, and AWS has a huge DevOps and web fleet/mobile apps base

Terraform users often overlap with eG Enterprise users, who choose a cloud-agnostic monitoring and AIOps solution vs. investing in native cloud tools and the associated vendor lock-in implications. Terraform can also be used for on-premises and cloud VDI solution vendors, such as VMware and Citrix.

In 2023 the licensing of Terraform changed away from the very permissive open osurce model it had used. Details of this can be found here, HashiCorp's Licensing Change is only the Latest Challenge to Open Source - The New Stack and HashiCorp Licensing Firestorm Fuels Open Source Debate (forbes.com). HashiCorp actively maintain a FAQ to allay user concerns and answer questions about this, see: HashiCorp Licensing FAQ.


How does Terraform work?

With Terraform, infrastructure is defined in code using a domain-specific language (DSL), typically written in HashiCorp Configuration Language (HCL). Users specify the desired state of their infrastructure in configuration files, including resources such as virtual machines, networks, storage, and more.

Terraform works by interpreting these configuration files and translating them into API calls to interact with the underlying infrastructure providers, such as AWS, Azure, Google Cloud Platform, or on-premises environments. It follows a state-based approach, where it maintains a state file to track the current state of deployed resources and reconcile it with the desired state defined in configuration files. This enables Terraform to determine the difference between the current and desired states and make the necessary changes to bring the infrastructure into the desired state.

A good overview of HCL is given in: Day 2 - Terraform Configuration Language (HCL) | by Fuzail Ahmed | Medium. For those interested in the full native syntax specification of HCL, please see: the HCL native syntax specification.


What languages does Terraform support?

Many organizations avoid using HCL directly especially if their employees' skillsets are focused on other languages. The Cloud Development Kit for Terraform (CDKTF) allows organizations to use familiar programming languages to define and provision infrastructure. See, CDK for Terraform | Terraform | HashiCorp Developer for details. The CDKTF supports languages including: TypeScript, Python, Java, C#, and Go.

Terraform also supports an alternative syntax that is JSON-compatible. This syntax is useful when generating portions of a configuration programmatically, since existing JSON libraries can be used to prepare the generated configuration files. See: JSON Configuration Syntax - Configuration Language | Terraform | HashiCorp Developer.


How can I use Terraform to deploy and configure monitoring tools such as eG Enterprise, Prometheus, Grafana, or Datadog?

Terraform can be used for deploying monitoring tools efficiently. It offers automation, scalability, and repeatability, enabling organizations to streamline the deployment process across various environments.

Terraform's provisioners automate the installation and configuration of monitoring tools, allowing users to specify commands or scripts for tool setup, configuration, and integration with other components in the monitoring ecosystem. Moreover, Terraform's dependency management ensures efficient orchestration of monitoring tool deployments, enabling the creation of modular and reusable configurations for consistent deployments across different environments.

The level of integration possible with any monitoring tool will be dependent of on the quality, depth and breadth of the APIs and interfaces it exposes to Terraform, information contained within APIs for IT Monitoring Solutions | eG Innovations will guide you when evaluating APIs for use with Terraform and similar technologies.

Additionally, Terraform's state management capabilities enable systematic tracking of deployed infrastructure states, ensuring consistent and reproducible monitoring tool configurations over time.

Overall, Terraform offers organizations a declarative, version-controlled, and automated approach to deploying monitoring tools, resulting in streamlined operations, improved scalability, and enhanced reliability of monitoring solutions.